import { legacy_createStore as createStore, applyMiddleware } from 'redux'
// 引入根 rootReducer
import rootReducer from './reducers'
// thunk 中间件
import thunk from 'redux-thunk'
// 浏览器 redux 插件 的配置
import { composeWithDevTools } from 'redux-devtools-extension'
// 获取token
import { getToken } from '@/utils'
// 获取在本地获取 Token
const initialState = {
    login: getToken() || '',
}
// 为 redux 设置默认状态，这样，即使刷新页面，此处提供的初始状态仍然有效
const middlewares = composeWithDevTools(applyMiddleware(thunk))
// 创建仓库
const store = createStore(rootReducer, initialState, middlewares)
// 导出仓库
export default store
